<template>
  <div class="page">
    <WatchMdEdier :text="content" />
  </div>
</template>

<script lang="ts" setup>
import { useQuestion } from "@/store/question";
import { storeToRefs } from "pinia";
import WatchMdEdier from "@/components/question/WatchMdEdier.vue";
import { computed } from "vue";

const question = useQuestion();
let { submit } = storeToRefs(question);

let content = computed(() => {
  let pre =
    "## 用户代码:\n```" +
    submit.value?.language +
    "\n" +
    submit.value?.code +
    "\n```\n## 结果:" +
    submit.value?.codeStatus +
    "\n**时间消耗:** " +
    (submit.value?.judgeInfo?.time == null ? 0 : submit.value.judgeInfo?.time) +
    "ms\n" +
    "**内存消耗:** " +
    (submit.value?.judgeInfo?.memory == null
      ? 0
      : submit.value?.judgeInfo?.memory) +
    "kb\n## 报错信息:\n";
  if (submit.value?.judgeInfo?.message) {
    pre += "```error\n" + submit.value.judgeInfo?.message + "\n```";
  } else {
    pre += "无";
  }
  return pre;
});
</script>

<style scoped>
.page {
  width: 100%;
}
</style>
